home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 08 - 1992 / 08.03 Jul 92 / Fast Random Numbers / RandomNumbers.p < prev    next >
Encoding:
Text File  |  1991-10-04  |  1.9 KB  |  58 lines  |  [TEXT/MPS ]

  1. UNIT RandomNumbers;
  2.  
  3. {  This unit provides the Pascal interface for the random
  4.    number generator implemented in RandomNumbers.a.
  5.  
  6.    This unit was written in MPW Pascal, v3.2.
  7.  
  8.                            Jon Bell
  9.               Dept. of Physics & Computer Science
  10.                      Presbyterian College
  11.                        Clinton SC 29325
  12.                     CompuServe: #70441,353
  13.                           October 1991                     }
  14.  
  15. INTERFACE
  16.  
  17. {----------------------------------------------------------}
  18.  
  19. procedure InitRandomSeed (newSeed : longint);
  20.  
  21. {  Initializes the random number seed to "newSeed".  You
  22.    must call this procedure once, at the beginning of your
  23.    program, before you use any of the following functions.
  24.    As far as randomness is concerned, it makes no difference
  25.    what value you use for "newSeed", so long as it isn't
  26.    zero.  Using different seeds merely gives you different
  27.    sequences of "random" numbers.  Using the same seed each
  28.    time you run the program gives you the same sequence of
  29.    "random" numbers each time, which may be useful for
  30.    debugging. }
  31.  
  32. {----------------------------------------------------------}
  33.  
  34. function RandomSeed : longint;
  35.  
  36. {   Returns the current value of the random number seed.   }
  37.  
  38. {----------------------------------------------------------}
  39.  
  40. function RandomReal : extended;
  41.  
  42. {  Returns a real number, uniformly "randomly" selected 
  43.    from the interval (0.0,1.0).  Note that this is an
  44.    "open" interval, that is, it does _not_ include 0.0 or
  45.    1.0.                                                    }
  46.  
  47. {----------------------------------------------------------}
  48.  
  49. function RandomInteger (max : longint) : longint;
  50.  
  51. {  Returns an integer, uniformly "randomly" selected from
  52.    the interval [1,max].  Note that this is a "closed"
  53.    interval, that is, it _does_ include 1 and max.         }
  54.  
  55. {----------------------------------------------------------}
  56.  
  57. END.
  58.